﻿export default function define(Blocks: Blockly.BlockDefinitions) {

  let graphcol = "#008FD1"

  Blocks['chart_type'] = {
    init: function() {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("name"), "name")
          .appendField(" = pygal.")
          .appendField(new Blockly.FieldDropdown([["折线图", "Line"], ["堆积折线图", "StackedLine"], ["柱状图", "Bar"], ["堆积柱状图", "StackedBar"], ["水平柱状图", "HorizontalBar"], ["水平堆积柱状图","StackedHorizontalBar"], ["点图","XY"],["派图","Pie"], ["雷达图","Radar"]]), "chartTypes")
          .appendField("(");
      this.appendValueInput("text")
          .setCheck(null);
      this.appendDummyInput()
          .appendField(")");
      this.setInputsInline(true);
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(graphcol);
   this.setTooltip("设定图标外观");
   this.setHelpUrl("");
    }
  };

  Blocks['chart_title'] = {
    init: function() {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("name"), "name")
          .appendField(".标题 = ");
      this.appendValueInput("text")
          .setCheck(null);
      this.setInputsInline(true);
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(graphcol);
   this.setTooltip("设置题目");
   this.setHelpUrl("");
    }
  };

  Blocks['chart_add'] = {
    init: function() {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("name"), "name")
          .appendField(".添加(");
      this.appendValueInput("text")
          .setCheck(null);
      this.appendDummyInput()
          .appendField(", [");
      this.appendValueInput("text1")
          .setCheck(null);
      this.appendDummyInput()
          .appendField("])");
      this.setInputsInline(true);
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(graphcol);
   this.setTooltip("添加值");
   this.setHelpUrl("");
    }
  };

  Blocks['chart_xlabels'] = {
    init: function() {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("name"), "name")
          .appendField(".X轴标签 = ");
      this.appendValueInput("text")
          .setCheck(null);
      this.setInputsInline(true);
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(graphcol);
   this.setTooltip("为X轴加标签");
   this.setHelpUrl("");
    }
  };

  Blocks['chart_render'] = {
    init: function() {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("name"), "name")
          .appendField(".提交");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(graphcol);
   this.setTooltip("提交图");
   this.setHelpUrl("");
    }
  };


}

